package com.zpphis.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zpphis.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zpp
 * @since 2022-11-22
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {
    @Select("SELECT\n" +
            "\tu.id,\n" +
            "\tu.username,\n" +
            "\tu.real_name,\n" +
            "\tut.user_type_name userType,\n" +
            "\tci.constant_name docTitle,\n" +
            "\tu.is_scheduling isSche,\n" +
            "\tdt.dept_type_name deptName,\n" +
            "\trl.regist_name registLe\n" +
            "FROM\n" +
            "\tt_user u\n" +
            "INNER JOIN t_user_type ut ON ut.id = u.user_type_id\n" +
            "INNER JOIN t_constant_item ci ON ci.id = u.doc_title_id\n" +
            "INNER JOIN t_department_type dt ON dt.id = u.dept_id\n" +
            "INNER JOIN t_regist_level rl ON rl.id = u.regist_le_id\n" +
            "WHERE\n" +
            "\tu.del_mark = 1\n" +
            "AND (\n" +
            "\tu.username LIKE #{queryString}\n" +
            "\tOR u.real_name LIKE #{queryString}\n" +
            "\tOR ut.user_type_name LIKE #{queryString}\n" +
            "\tOR ci.constant_name LIKE #{queryString}\n" +
            "\tOR dt.dept_type_name LIKE #{queryString}\n" +
            "\tOR rl.regist_name LIKE #{queryString}\n" +
            ")")
    Page<Map<String, Object>> selectPageExtend(Page<Map<String, Object>> p, String queryString);
}
